package stringFunctions;

/**
 *
 * @author g1wshimu
 */
public class Stringify {
    
    private Stringify(){}
    
    /**
     * Returns the infinity sign if the given num equals Integer.MAX_VALUE,
     * returns the negative infinity sign if the given num equals 
     * Integer.MIN_VALUE, otherwise return the regular String representation
     * of num.
     * @param num
     * @return 
     */
    public static String intToString(int num) {
        if (num == Integer.MAX_VALUE) {
            return "\u221E";
        } else if (num == Integer.MIN_VALUE) {
            return "-\u221E";
        }
        return Integer.toString(num);
    }
    
    /**
     * Given an array of bytes, output in Hex the value of each byte each on
     * a separate line.
     * 
     * @param bytes 
     */
    public static String toHexString(byte[] bytes) {
        String[] hex = new String[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            hex[i] = Integer.toHexString(bytes[i]);
        }
        return StringFunctions.insertSeparator(hex, " ");
    }
}
